#!/usr/bin/env python

from PIL import Image
import re

im = Image.open('mozart.gif')
w, h = im.size
pix = im.load()
for y in range(h):
    line = [pix[x, y] for x in range(w)]
    str_line = ''
    for x in range(w):
        str_line += chr(line[x])
    mo = re.search('\xC3{5}', str_line)
    new_line = line[mo.start(0):] + line[:mo.start(0)]
    for x in range(w):
        pix[x, y] = new_line[x]
im.save('mozart_res.gif')

